let app = getApp()

var {
  Api
} = require('../../api/api')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show:{
      type:Boolean,
      value:false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    domain: Api.domain,
  },
  lifetimes:{
    show(){
      wx.login({
        success(res){
          app.code = res.code
        }
      })
      
    },
    attached: function() {
      // 在组件实例进入页面节点树时执行
      console.log("09090909090909");
      this.bangsss();
      
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
     //取消手机号获取
     bangsss(){//绑定手机号
      var that = this;
      let phone=0;
      var params = {
        mobile:phone
      }
      /*
      wx.$http.post(wx.$get.update_member,params).then(res=>{
        console.log('绑定手机号', res)
        that.setData({
          show:false
        })
        if(res=='操作成功'){
          wx.$cache.set('phone',phone)
        }
      })
      */
    },


    getPhoneNumber(e){
      var that = this
    var params = {
      code:app.code,
      encryptedData:e.detail.encryptedData,
      iv:e.detail.iv,
      session_key:wx.$cache.get('key')
    }
    wx.$http.post(wx.$get.decryption,params).then(res=>{
      console.log('获取手机号', res)
      that.bang(res)
    }).catch(()=>{
      wx.login({
        success(res){
          app.code = res.code
        }
      })
    })
    },
    closethis1() {
      this.setData({
        show: false
      })
      wx.switchTab({
       
        url: '/pages/index/index',
      })
    },
    bang(e){//绑定手机号
      var that = this
      var params = {
        mobile:e
      }
      /*
      wx.$http.post(wx.$get.update_member,params).then(res=>{
        console.log('绑定手机号', res)
        that.setData({
          show:false
        })
        if(res=='操作成功'){
          wx.$cache.set('phone',e)
        }
      })
      */
    }
  },
  
})
